package xian.woniuxy.hisbe.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author zhang
 * @time 2022/01/02 10:38:18
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResultVO {
    private int code;
    private String msg;
    private Object data;

    public ResultVO(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    //静态工厂成功
    public static ResultVO success(){
        return success("操作成功", null);
    }
    public static ResultVO success(String msg){
        return success(msg,null);
    }

    public static ResultVO success(Object data) {
        return success("操作成功", data);
    }

    public static ResultVO success(String msg, Object data) {
        return new ResultVO(200,msg,data);
    }

    //静态工厂 失败
    public static ResultVO failure(String msg, Object data) {
        return new ResultVO(500, msg, data);
    }

    public static ResultVO failure(String msg) {
        return failure(msg, null);
    }

    public static ResultVO failure(Object data) {
        return failure("操作失败", data);
    }
    public static ResultVO failure() {
        return failure("操作失败", null);
    }

    public static ResultVO failure(int code, String msg) {
        return new ResultVO(code, msg, null);
    }
}
